<!doctype html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>收货地址</title>
		<script src="__PUBLIC__/Home/Js/jquery.js"></script>
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/Css/getaddress.css">
		<script src="__PUBLIC__/Home/Js/area.js"></script>
		<script src="__PUBLIC__/Home/Js/PCASClass.js"></script>
	</head>
	<body>
		<div id="get_head">
			<span>收货地址</span>
		</div>
		<div id="get_main">
			<div class="get_main_up">
				<p style="width:100px;">收货人</p>
				<p style="width:490px;">详细地址</p>
				<p style="width:180px;">手机/电话</p>
				<p style="width:100px;">操作</p>
			</div>
			<!-- 遍历输出已经添加的收货地址信息 -->
			<div class="get_main_middle">
				<if condition="$address eq null">
					您还没有保存任何收货地址
				<else />
					<foreach name="address" item="ad">							 
						<div class="get_address_list">
							<p style="width:100px;">{$ad.name}</p>
							<p style="width:500px;">{$ad.address}</p>
							<p style="width:170px;">{$ad.phone}</p>
							<p style="width:100px;">
								<if condition="$ad.status eq 1"><img src="__PUBLIC__/Home/Images/default_addr_icon.jpg" alt=""  /></if>
								<a href="javascript::" title="{$ad.id}" class="edit_addr" style="color:red;text-decoration:none;">编辑</a>|<a href="__CONTROLLER__/deladdress/id/{$ad.id}" style="color:red;text-decoration:none;">删除</a>
							</p>
						</div>
					</foreach>
				</if>
			</div>
			<div class="get_add_address">
				<a style="cursor:pointer;" id="add_addr_btn">添加新地址&nbsp;<img src="__PUBLIC__/Home/Images/add_addr_up.jpg" class="double_arrows" /></a>
			</div>
			<!-- 添加收货人地址表单 -->
			<div id="add_addr_form">
				<form action="__CONTROLLER__/addaddress/id/{$user.id}" method="post">
					<!-- 收货人姓名 -->
					<div class="addr_info_put" style="margin-top:15px;">
						<span>*</span>收货人:
						<input type="text" name="name" style="margin-left:23px;height:20px;width:180px;" placeholder="请准确填写真实姓名" />
					</div>
					<!-- 收货人所在地区 -->
					<div class="addr_info_put">
						<span>*</span><a style="margin-right:43px;">地区:</a>{$city}
					</div>
					<!-- 收货人详细地址 -->
					<div class="addr_info_put">
						<span>*</span>详细地址:
						<input type="text" name="address" style="margin-left:10px;height:20px;width:260px;margin-right:10px;" placeholder="请填写详细路名及门牌号" />配送范围与配送时间
					</div>
					<!-- 收货人所在地区的邮编 -->
					<div class="addr_info_put">
						<span>*</span>邮政编码:
						<input type="text" name="zipcode" style="margin-left:10px;height:20px;width:130px;" placeholder="请填写邮政编码" />
					</div>
					<!-- 现在可以联系到收货人的手机号 -->
					<div class="addr_info_put">
						<span>*</span>手机号:
						<input type="tel" name="phone" style="margin-left:23px;height:20px;width:200px;" placeholder="请填写正用的手机号" />
					</div>
					<!-- 设置默认收货地址 -->
					<div style="padding-left:149px;margin-top:3px;">
						<span style="width:100px;"></span>
						<input type="checkbox" name="status" value="1" />
						<span style="color:#a10000;font-size:13px;margin-left:10px;">设置为默认收货地址</span>
					</div>
					<!-- 添加新收货地址按钮 -->
					<div style="padding-left:149px;margin-top:5px;">
						<span style="width:100px;"></span>
						<input type="image" src="__PUBLIC__/Home/Images/addthisaddr_btn.jpg" />
					</div>										
				</form>

				<form action="__CONTROLLER__/updAddress/id/" id="edit_addr_form" method="post">

					<!-- 隐藏的地址编辑窗口 -->
					<div id="hidden_edit_addr">
						<p style="height:35px;line-height:35px;background:#BD3333;"><span style="font-size:13px;margin-left:20px;color:white;text-decoration:underline;">编辑收货地址</span><a href="javascript::" style="margin-left:720px;font-size:13px;text-decoration:none;color:white;" class="close_div_btn">[<img src="__PUBLIC__/Home/Images/close_edit_addr_btn.jpg" alt="">关闭]</a></p>
						<div>
							<!-- 收货人姓名 -->
							<div class="addr_info_put" style="margin-top:15px;">
								<span>*</span>收货人:
								<input type="text" name="name" style="margin-left:23px;height:20px;width:180px;" placeholder="请准确填写真实姓名" id="get_goods_people" value="" />
							</div>
							<!-- 收货人所在地区 -->
							<div class="addr_info_put">
								<span>*</span><a style="margin-right:35px;">地区:</a>
								<select name="province3"></select>
								<select name="city3"></select>
								<select name="area3"></select>
								
							</div>
							<!-- 原来的收货地址 -->
							<p id="old_get_addr" style="width:400px;margin-left:150px;font-size:13px;color:#666666;"></p>
							<!-- 收货人详细地址 -->
							<div class="addr_info_put">
								<span>*</span>详细地址:
								<input type="text" name="address" style="margin-left:10px;height:20px;width:260px;margin-right:10px;" placeholder="请填写详细路名及门牌号" value="" id="get_goods_addr"/>配送范围与配送时间
							</div>
							<!-- 收货人所在地区的邮编 -->
							<div class="addr_info_put">
								<span>*</span>邮政编码:
								<input type="text" name="zipcode" style="margin-left:10px;height:20px;width:130px;" placeholder="请填写邮政编码" value="" id="get_goods_postcode" />
							</div>
							<!-- 现在可以联系到收货人的手机号 -->
							<div class="addr_info_put">
								<span>*</span>手机号:
								<input type="tel" name="phone" style="margin-left:23px;height:20px;width:200px;" placeholder="请填写正用的手机号" value="" id="get_goods_phone"/>
							</div>
							<!-- 设置默认收货地址 -->
							<div style="padding-left:149px;margin-top:3px;">
								<span style="width:100px;"></span>
								<input type="checkbox" name="status" value="1" id="default_get_goods" />
								<span style="color:#a10000;font-size:13px;margin-left:10px;">设置为默认收货地址</span>
							</div>
							<div><input type="submit" value="保存地址" style="background:#A20000;border:1px solid #A20000;width:80px;height:23px;margin:10px auto 15px 150px;color:white;"/></div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</body>
	<script>

		new PCAS("province3","city3","area3");

		//添加收货地址按钮的单击事件
		$("#add_addr_btn").click(function() {
			if ($("#add_addr_form").css("display") == "none") {
				$("#add_addr_form").css("display","block");	
				$(".double_arrows").attr("src","__PUBLIC__/Home/Images/add_addr_up.jpg");		
			} else {
				$("#add_addr_form").css("display","none");
				$(".double_arrows").attr("src","__PUBLIC__/Home/Images/add_addr_dw.jpg");
			}
		});

		//编辑地址链接的单击事件
		$(".edit_addr").click(function() {
			$("#hidden_edit_addr").css({'display':'block'});
			$id = $(this).attr('title');
			$.post("__CONTROLLER__/modaddr", {'id':$id}, function(data) {
				$("#get_goods_people").val(data['name']);
				$("#get_goods_addr").val(data['address']);
				$("#get_goods_postcode").val(data['zipcode']);
				$("#get_goods_phone").val(data['phone']);
				if (data['status'] == 1) {
					$("#default_get_goods").attr("checked","checked");
				}
				$("#edit_addr_form").attr('action',"__CONTROLLER__/updAddress/id/"+$id);
				$("#old_get_addr").html(data['pname']+","+data['cname']+","+data['county']);
				
			},"json");
		});

		//关闭按钮单击事件
		$(".close_div_btn").click(function() {
			$("#hidden_edit_addr").css({"display":"none"});
		});
	</script>
</html>